package operation;

import Book.Booklist;

import java.util.Scanner;

/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2022-05-23
 * Time:21:27
 */
public class BorrowOperation implements IOperation{

    @Override
    public void work(Booklist booklist) {
        System.out.println("借阅图书");
        System.out.println("请输入您需要借阅的图书:");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        for (int i = 0; i < booklist.getUsedSize(); i++) {
            if (!(booklist.getBooks(i).isBorrowed())&&(name.equals(booklist.getBooks(i).getName()))){
                booklist.getBooks(i).setBorrowed(true);
                System.out.println("借阅成功！");
                return;
            }
        }
        System.out.println("该书借出！");
    }
}
